package cz.muni.fi.pa165.soap;

import cz.muni.fi.pa165.dto.EmployeeDTO;
import cz.muni.fi.pa165.login.Authenticator;
import cz.muni.fi.pa165.service.local.impl.EmployeeService;
import java.util.List;
import javax.inject.Inject;
import javax.jws.WebService;

/**
 *
 * @author <a href="mailto:vramik at redhat.com">Vlastislav Ramik</a>
 */
@WebService(endpointInterface = "cz.muni.fi.pa165.soap.EmployeeSoapService", serviceName = "employeeService")
public class EmployeeSoapServiceImpl implements EmployeeSoapService {

    @Inject
    EmployeeService employeeService;

    @Inject
    Authenticator a;
    private String id="4";
    private String pass="rest";
    
    private void login(){
        a.setUsername(this.id);
        a.setPassword(pass);
        a.login();
    }
    
    @Override
    public EmployeeDTO getEmployee(Long id) {
        login();
        return employeeService.getEmployeeById(id);
    }

    @Override
    public List<EmployeeDTO> getEmployees() {
        login();
        return employeeService.getAllEmployees();
    }

    @Override
    public Long createEmployee(EmployeeDTO employee) {
        login();
        return employeeService.createEmployee(employee);
    }

    @Override
    public void removeEmployee(EmployeeDTO employee) {
        login();
        employeeService.removeEmployee(employee);
    }

    @Override
    public void updateEmployee(EmployeeDTO employee) {
        login();
        employeeService.updateEmployee(employee);
    }
}
